package com.lib.common.view;

import android.content.Context;
import androidx.core.widget.NestedScrollView;
import android.util.AttributeSet;
import android.view.MotionEvent;

/**
 * @author 一叶丶枫凌
 * Created on 2016-12-14 2:09
 */
public class MyNestedScrollView extends NestedScrollView {
    private boolean mEnableScroll = true;

    public MyNestedScrollView(Context context) {
        this(context, null);
    }

    public MyNestedScrollView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public MyNestedScrollView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    public boolean isEnableScroll() {
        return mEnableScroll;
    }

    public void setEnableScroll(boolean enableTouch) {
        mEnableScroll = enableTouch;
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent event) {
        return mEnableScroll && super.onInterceptTouchEvent(event);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        return mEnableScroll && super.onTouchEvent(event);
    }
}